import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { list as deviceTypeList } from '../deviceType/deviceType.api';
import { h } from 'vue';
import { Icon } from '/@/components/Icon';
import { render } from '/@/utils/common/renderUtils';
import { isNullOrUnDef, isEmpty } from '/@/utils/is';

export const columns: BasicColumn[] = [
  {
    title: '设备类型',
    dataIndex: 'typeName',
    width: 200,
    align: 'left',
  },
  {
    title: '型号',
    dataIndex: 'model',
    width: 200,
    align: 'left',
  },
  {
    title: '型号说明',
    dataIndex: 'remark',
    width: 200,
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'model',
    label: '设备型号',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '设备类型',
    field: 'typeId',
    required: true,
    component: 'ApiTreeSelect',
    componentProps: {
      api: deviceTypeList,
      immediate: true,
      expandAll: true,
      resultField: 'data',
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
      dropdownStyle: {
        maxHeight: '50vh',
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '设备型号',
    field: 'model',
    required: true,
    component: 'Input',
  },
  {
    label: '类型说明',
    field: 'remark',
    component: 'Input',
  },
];